﻿using System;
using System.Text;
using System.Drawing;
using System.Buffers;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;

public static partial class NativeAOT
{
    [UnmanagedCallersOnly(EntryPoint = "chii")]
    public static unsafe double chii_dll(double x, int n)
    {
        return chii(x, n);
    }

    /// <summary>
    /// X平方分布函数
    /// </summary>
    /// <param name="x">自变量值。</param>
    /// <param name="n">自由度。</param>
    /// <returns>返回X平方分布函数值。</returns>
    public static unsafe double chii(double x, int n)
    {
        double y;
        if (x < 0.0) x = -x;
        y = ingamma(n / 2.0, x / 2.0);
        return (y);
    }

    /*
    // X平方分布函数例
      int main()
      { 
          int n;
          double t,y;
          for (n=1; n<=5; n++)
          { 
              t=0.5; y=chii(t,n);
              cout <<"P(" <<t <<", " <<n <<")=" <<y <<endl;
              t=5.0; y=chii(t,n);
              cout <<"P(" <<t <<", " <<n <<")=" <<y <<endl;
          }
          return 0;
      }
    */
}

